package com.zhangxin.designmode.oop.demo2;

/**
 * 多态 示例
 *
 * @author zhangxin
 * @date 2022/4/3
 */
public class DemoMain {
    public static void main(String[] args) {
        Iterator arrayIterator = new Array();
        print(arrayIterator);

        Iterator linkedListIterator = new Array();
        print(linkedListIterator);
    }

    private static void print(Iterator iterator) {
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }

}
